package com.zprmb.udzt;

import java.text.DecimalFormat;

import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.zprmb.udzt.ll.BaseHelper;
/**
 * 累计收益
 * @author shenshao
 *
 */
public class Accumulated_earnings extends BaseActivity implements OnClickListener{
	private ImageView img_back,img_new_info,img_old_info;
	private TextView tv_total,tv_current,tv_red,tv_comm,tv_exe,tv_san,tv_coupon;
	DecimalFormat df = new DecimalFormat("###0.00");
	private RelativeLayout rl_back,rl_uplan_old,rl_uplan_new;;
	private LinearLayout li_uplan_old,li_uplan_new;
	private TextView tv_customer;
	private Double allAssetReceivedInterest;//定期理财已收利息
	private Double allAssetReceivedAddInterest;//定期理财加息券已收收益
	private Double allAssetReceivedAfterAddInterest;//定期理财平台附加利息
	private Double allFixedInterest;//定期计划已收利息
	private Double totalRateRaisingRecInterest;//定期计划加息券已收收益
	private TextView tv_new_total,tv_old_total,tv_uplan_new_pl;
	private TextView tv_uplan_new_benxi,tv_uplan_old_benxi;
	private TextView tv_uplan_new_coupon,tv_uplan_old_coupon;
	@Override 
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.accumulated_earnings);
		 BbtApplication.getInstance().addActvity(this);
		img_back=(ImageView)findViewById(R.id.img_back);
		tv_total=(TextView)findViewById(R.id.total_due);
		tv_current=(TextView)findViewById(R.id.current_income);
		tv_uplan_new_pl=(TextView)findViewById(R.id.tv_uplan_new_pl);
		 img_new_info=(ImageView)findViewById(R.id.img_new_info);
		 img_old_info=(ImageView)findViewById(R.id.img_old_info);
		 tv_uplan_new_coupon=(TextView)findViewById(R.id.tv_uplan_new_coupon);
		 tv_uplan_old_coupon=(TextView)findViewById(R.id.tv_uplan_old_coupon);
		 tv_uplan_new_benxi=(TextView)findViewById(R.id.tv_uplan_new_benxi);
		 tv_uplan_old_benxi=(TextView)findViewById(R.id.tv_uplan_old_benxi);
		 li_uplan_old=(LinearLayout)findViewById(R.id.li_uplan_old);
		 li_uplan_new=(LinearLayout)findViewById(R.id.li_uplan_new);
		 rl_uplan_old=(RelativeLayout)findViewById(R.id.rl_uplan_old);
		 rl_uplan_new=(RelativeLayout)findViewById(R.id.rl_uplan_new);
		 tv_new_total=(TextView)findViewById(R.id.tv_new_total);
		 tv_old_total=(TextView)findViewById(R.id.tv_old_total);
		tv_red=(TextView)findViewById(R.id.red_income);
		tv_comm=(TextView)findViewById(R.id.comm_income);
		tv_exe=(TextView)findViewById(R.id.exe_income);
		rl_back=(RelativeLayout)findViewById(R.id.rl_back);
		tv_customer=(TextView)findViewById(R.id.enterprise_tel);
		tv_san=(TextView)findViewById(R.id.san_income);
		tv_coupon=(TextView)findViewById(R.id.coupon_income);
		rl_uplan_old.setOnClickListener(this);
		rl_uplan_new.setOnClickListener(this);
		tv_customer.setOnClickListener(this);
		rl_back.setOnClickListener(this);
		allAssetReceivedInterest=getIntent().getDoubleExtra("allAssetReceivedInterest", 0);
		allAssetReceivedAddInterest=getIntent().getDoubleExtra("allAssetReceivedAddInterest", 0);
		allAssetReceivedAfterAddInterest=getIntent().getDoubleExtra("allAssetReceivedAfterAddInterest", 0);
		allFixedInterest=getIntent().getDoubleExtra("allFixedInterest", 0);
		totalRateRaisingRecInterest=getIntent().getDoubleExtra("totalRateRaisingRecInterest", 0);
		
		tv_new_total.setText(df.format(allAssetReceivedInterest+allAssetReceivedAddInterest+allAssetReceivedAfterAddInterest));
		tv_old_total.setText(df.format(allFixedInterest+totalRateRaisingRecInterest));
		tv_uplan_new_benxi.setText(df.format(allAssetReceivedInterest));
		tv_uplan_new_coupon.setText(df.format(allAssetReceivedAddInterest));
		tv_uplan_new_pl.setText(df.format(allAssetReceivedAfterAddInterest));
		tv_uplan_old_benxi.setText(df.format(allFixedInterest));
		tv_uplan_old_coupon.setText(df.format(totalRateRaisingRecInterest));
		tv_total.setText(df.format(Double.parseDouble(getIntent().getStringExtra("interest"))));
		tv_current.setText(df.format(Double.parseDouble(getIntent().getStringExtra("current"))));
		
		tv_red.setText(df.format(Double.parseDouble(getIntent().getStringExtra("red"))));
		tv_comm.setText(df.format(Double.parseDouble(getIntent().getStringExtra("yongjin"))));
		tv_exe.setText(df.format(Double.parseDouble(getIntent().getStringExtra("exe"))));
		tv_san.setText(df.format(Double.parseDouble(getIntent().getStringExtra("san"))));
		tv_coupon.setText(df.format(Double.parseDouble(getIntent().getStringExtra("coupon"))));
		img_back.setOnClickListener(new OnClickListener() {
			
			@Override
			public void onClick(View v) {
				// TODO Auto-generated method stub
				finish();
			}
		});
	}
	@Override
	protected void onDestroy() {
		// TODO Auto-generated method stub
		super.onDestroy();
		BbtApplication.getInstance().removeActvity(this);
	}
	private void imgchange_old(){
		if(li_uplan_old.getVisibility()==View.GONE){
			
			li_uplan_old.setVisibility(View.VISIBLE);
			img_old_info.setImageResource(R.drawable.icon_up);
		}else{
			li_uplan_old.setVisibility(View.GONE);
			img_old_info.setImageResource(R.drawable.icon_down);
		}
	}
	private void imgchange_new(){
		if(li_uplan_new.getVisibility()==View.GONE){
			
			li_uplan_new.setVisibility(View.VISIBLE);
			img_new_info.setImageResource(R.drawable.icon_up);
		}else{
			li_uplan_new.setVisibility(View.GONE);
			img_new_info.setImageResource(R.drawable.icon_down);
		}
	}
	@Override
	public void onClick(View v) {
		// TODO Auto-generated method stub
		switch(v.getId()){
		case R.id.rl_back:
			finish();
			break;

       case R.id.enterprise_tel:
			BaseHelper.showDialog2(this, "拨号", "400-0101-016", 1);
			break;
       case R.id.rl_uplan_old:
			imgchange_old();
			break;
		case R.id.rl_uplan_new:
			imgchange_new();
			break;
		}
	}
}
